package cn.ssj.controller;

import cn.ssj.entity.Enterprise;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/9/5 0005.
 */
@RestController
@EnableAutoConfiguration
public class EnterpriseController extends BaseController<Enterprise,Integer>{

    @RequestMapping("/back/addEnterprise")
    public String add(Enterprise entity) {
        entity.setUseFlag(USE_FLAG_NORMAL);
        entity.setLogo(super.filePath);
        return super.add(entity);
    }

    @RequestMapping("/back/updateEnterprise")
    public String update(Enterprise entity) {
        entity.setLogo(super.filePath);
        return super.update(entity);
    }

    @RequestMapping("/back/deleteEnterprise")
    public String delete(@RequestParam("ids[]") Integer[] ids) {
        return super.delete(ids);
    }

    @RequestMapping("/back/queryAllEnterpriseByPage")
    public String queryAllByPage(Integer pageNumber) {
        return super.queryAllByPage(pageNumber);
    }

    @RequestMapping("/back/enterpriseUpload")
    public String upload(MultipartFile file, HttpServletRequest request) {
        super.setLocationPath(getLocationPath()+ "enterprise");
        super.setHandlerPath(getHandlerPath()+"enterprise");
        return super.upload(file, request);
    }
}
